<?php 

/**
*
*
*
**/


// Load the common classes
require_once('includes/common/KT_common.php');
// Load the tNG classes
require_once('includes/tng/tNG.inc.php');
// Make a transaction dispatcher instance
$tNGs = new tNG_dispatcher("");

// Start trigger
$formValidation = new tNG_FormValidation();
$formValidation->addField("email_persona", true, "text", "email", "", "", "");
$tNGs->prepareValidation($formValidation);
// End trigger

//start Trigger_ForgotPasswordCheckEmail trigger
//remove this line if you want to edit the code by hand
function Trigger_ForgotPasswordCheckEmail(&$tNG) {
  return Trigger_ForgotPassword_CheckEmail($tNG);
}
//end Trigger_ForgotPasswordCheckEmail trigger

//start Trigger_ForgotPassword_Email trigger
//remove this line if you want to edit the code by hand
function Trigger_ForgotPassword_Email(&$tNG) {
   $emailObj = new tNG_Email($tNG);
  $emailObj->setFrom("{KT_defaultSender}");
  $emailObj->setTo("{email_persona}");
  $emailObj->setCC("");
  $emailObj->setBCC("");
  $emailObj->setSubject("Forgot password email");
  //FromFile method
   $emailObj->setContentFile("includes/mailtemplates/forgot.html");
   $emailObj->setEncoding("ISO-8859-1");
   $emailObj->setFormat("HTML/Text");
   $emailObj->setImportance("Normal");
   return $emailObj->Execute();
}
//end Trigger_ForgotPassword_Email trigger

// Make an update transaction instance
$forgotpass_transaction = new tNG_update($cn);
$tNGs->addTransaction($forgotpass_transaction);
// Register triggers
$forgotpass_transaction->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Update1");
$forgotpass_transaction->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);
$forgotpass_transaction->registerTrigger("BEFORE", "Trigger_ForgotPasswordCheckEmail", 20);
$forgotpass_transaction->registerTrigger("AFTER", "Trigger_ForgotPassword_Email", 1);
$forgotpass_transaction->registerTrigger("END", "Trigger_Default_Redirect", 99, "{kt_login_redirect}");
// Add columns
$forgotpass_transaction->setTable("vs_usuario");
$forgotpass_transaction->addColumn("email_persona", "STRING_TYPE", "POST", "email_persona");
$forgotpass_transaction->setPrimaryKey("email_persona", "STRING_TYPE", "POST", "email_persona");

// Execute all the registered transactions
$tNGs->executeTransactions();

// Get the transaction recordset
$rsvs_usuario = $tNGs->getRecordset("vs_usuario");
$totalRows_rsvs_usuario = $rsvs_usuario->RecordCount();

function cargar($vista){
	global $tNGs, $formValidation, $forgotpass_transaction, $rsvs_usuario;
	if (file_exists($vista)){
		//die($vista);
		require($vista);
		}
	else
		error_archivo($accion);
}
?>